package com.lcb.manager.web;

import com.lcb.manager.configuration.Config;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    @RequestMapping(value = "/")
    public String index() {
        return "login";
    }

    @RequestMapping(value = "/login")
    public String login(@RequestParam String pwd, HttpSession session) {
        if (pwd.equals(Config.password)) {
            session.setAttribute("is_login", true);
            return "redirect:/coal/";
        } else {
            return "login";
        }
    }
}
